package com.zhisheng.config;

import com.zhisheng.interceptor.MyLoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/*
* 拦截器配置类
* 自定义拦截路径
*/
@Configuration
public class MyInterceptorConfig implements WebMvcConfigurer {
    // 注册拦截器
    @Autowired
    private MyLoginInterceptor myLoginInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册的同时标明拦截哪些路径，不拦截哪些路径
        // /** 表示任意路径且任意层级  /*表示任意一层路径 filter中没有/** /*已经表示任意层级
        registry.addInterceptor(myLoginInterceptor).addPathPatterns("/**")
                .excludePathPatterns("/login");

    }
}
